"""
@Author：十
@Time：2024/11/5 15:58
@FileName：logging.py
@Description：日志管理
"""

import logging
from datetime import datetime

# mouth = current_year_month = datetime.now().strftime("%Y%m")

# logging.basicConfig(
#     filename=f'./log/{datetime.now().strftime("%Y%m")}.log',
#     level=logging.INFO,
#     format='%(asctime)s - %(levelname)s - %(message)s'
# )

# # 创建日志记录器
# logger = logging.getLogger('my_logger')
# logger.setLevel(logging.DEBUG)
#
# # 创建处理器 - 输出到文件
# file_handler = logging.FileHandler(f'./log/{datetime.now().strftime("%Y%m")}.log')
# file_handler.setLevel(logging.WARNING)
#
# # 创建处理器 - 输出到控制台
# console_handler = logging.StreamHandler()
# console_handler.setLevel(logging.DEBUG)
#
# # 设置日志格式
# formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# file_handler.setFormatter(formatter)
# console_handler.setFormatter(formatter)
#
# # 添加处理器到日志记录器
# logger.addHandler(file_handler)
# logger.addHandler(console_handler)
#
# # 记录日志
# logger.debug('调试信息')
# logger.info('普通信息')
# logger.warning('警告信息')
# logger.error('错误信息')
# logger.critical('严重错误信息')


from loguru import logger


def setup_logging():
    logger.add(f'./log/{datetime.now().strftime("%Y%m")}.log')

# logger.info('this is a info')
# logger.debug('this is a debug')
# logger.warning('this is a warning')
# logger.error('this is a error')
# logger.critical('this is a critical error')
